#region using
using System;
using System.Collections;
using System.Collections.Generic;
using System.Xml;

using XmlGenSharp.Lib.Utility;
#endregion

#region pragmas
#pragma warning disable 0219
#endregion

namespace Demo.DbmlReader
{
  public partial class Database
  {
    // Constructors

    #region Database(string filename)
    public Database(string filename)
    {
      XmlDocument xml = new XmlDocument();
      xml.Load(filename);
      LoadFromXmlNode(xml.DocumentElement);
    }
    #endregion

    #region Database(XmlDocument xml)
    public Database(XmlDocument xml)
    {
      LoadFromXmlNode(xml.DocumentElement);
    }
    #endregion

    #region Database(XmlNode node)
    public Database(XmlNode node)
    {
      LoadFromXmlNode(node);
    }
    #endregion

    // Public Properties

    #region Name
    public string Name
    {
      get;
      protected set;
    }
    #endregion

    #region EntityNamespace
    public string EntityNamespace
    {
      get;
      protected set;
    }
    #endregion

    #region ContextNamespace
    public string ContextNamespace
    {
      get;
      protected set;
    }
    #endregion

    #region Class
    public string Class
    {
      get;
      protected set;
    }
    #endregion

    #region AccessModifier
    public AccessModifier AccessModifier
    {
      get;
      protected set;
    }
    #endregion

    #region Modifier
    public ClassModifier Modifier
    {
      get;
      protected set;
    }
    #endregion

    #region BaseType
    public string BaseType
    {
      get;
      protected set;
    }
    #endregion

    #region Provider
    public string Provider
    {
      get;
      protected set;
    }
    #endregion

    #region ExternalMapping
    public bool ExternalMapping
    {
      get;
      protected set;
    }
    #endregion

    #region Serialization
    public SerializationMode Serialization
    {
      get;
      protected set;
    }
    #endregion

    #region EntityBase
    public string EntityBase
    {
      get;
      protected set;
    }
    #endregion

    #region Connection
    public Connection Connection
    {
      get;
      protected set;
    }
    #endregion

    #region Tables
    public List<Table> Tables
    {
      get
      {
        if (_tables == null)
          _tables = new List<Table>();

        return _tables;
      }
      protected set
      {
        _tables = value;
      }
    }
    private List<Table> _tables = null;
    #endregion

    #region Functions
    public List<Function> Functions
    {
      get
      {
        if (_functions == null)
          _functions = new List<Function>();

        return _functions;
      }
      protected set
      {
        _functions = value;
      }
    }
    private List<Function> _functions = null;
    #endregion

    // Private Methods

    #region LoadFromXmlNode(XmlNode node)
    private void LoadFromXmlNode(XmlNode node)
    {
      Name = XmlUtil.GetAttrib(node, "Name", "");
      EntityNamespace = XmlUtil.GetAttrib(node, "EntityNamespace", "");
      ContextNamespace = XmlUtil.GetAttrib(node, "ContextNamespace", "");
      Class = XmlUtil.GetAttrib(node, "Class", "");
      AccessModifier = AccessModifier.Parse(XmlUtil.GetAttrib(node, "AccessModifier", ""));
      Modifier = ClassModifier.Parse(XmlUtil.GetAttrib(node, "Modifier", ""));
      BaseType = XmlUtil.GetAttrib(node, "BaseType", "");
      Provider = XmlUtil.GetAttrib(node, "Provider", "");
      ExternalMapping = XmlUtil.GetBoolAttrib(node, "ExternalMapping", false);
      Serialization = SerializationMode.Parse(XmlUtil.GetAttrib(node, "Serialization", ""));
      EntityBase = XmlUtil.GetAttrib(node, "EntityBase", "");

      ParseNodes(node);
    }
    #endregion

    #region ParseSection1Nodes(XmlNode parent, ref IEnumerator enumerator, ref bool more)
    private void ParseSection1Nodes(XmlNode parent, ref IEnumerator enumerator, ref bool more)
    {
      int seqState = 0;

      for (bool done=false; more && !done;)
      {
        XmlNode node = enumerator.Current as XmlNode;

        switch (node.Name.ToLower())
        {
          case "connection":
            if (seqState > 0)
              throw new Exception("Elements out of sequence");

            seqState = 0;
            Connection = new Connection(node);
            break;

          case "table":
            if (seqState > 1)
              throw new Exception("Elements out of sequence");

            seqState = 1;

            Table elemTable = new Table(node);
            if (elemTable != null)
              Tables.Add(elemTable);
            break;

          case "function":
            if (seqState > 2)
              throw new Exception("Elements out of sequence");

            seqState = 2;

            Function elemFunction = new Function(node);
            if (elemFunction != null)
              Functions.Add(elemFunction);
            break;

          default:
            done = true;
            break;
        }

        if (!done)
          more = enumerator.MoveNext();
      }
    }
    #endregion

    #region ParseNodes(XmlNode parent)
    private void ParseNodes(XmlNode parent)
    {
      IEnumerator enumerator = parent.ChildNodes.GetEnumerator();
      bool more = enumerator.MoveNext();
      ParseSection1Nodes(parent, ref enumerator, ref more);
    }
    #endregion
  }

  public partial class Table
  {
    // Constructors

    #region Table(string filename)
    public Table(string filename)
    {
      XmlDocument xml = new XmlDocument();
      xml.Load(filename);
      LoadFromXmlNode(xml.DocumentElement);
    }
    #endregion

    #region Table(XmlDocument xml)
    public Table(XmlDocument xml)
    {
      LoadFromXmlNode(xml.DocumentElement);
    }
    #endregion

    #region Table(XmlNode node)
    public Table(XmlNode node)
    {
      LoadFromXmlNode(node);
    }
    #endregion

    // Public Properties

    #region Name
    public string Name
    {
      get;
      protected set;
    }
    #endregion

    #region Member
    public string Member
    {
      get;
      protected set;
    }
    #endregion

    #region AccessModifier
    public AccessModifier AccessModifier
    {
      get;
      protected set;
    }
    #endregion

    #region Modifier
    public MemberModifier Modifier
    {
      get;
      protected set;
    }
    #endregion

    #region Type
    public Type Type
    {
      get;
      protected set;
    }
    #endregion

    #region InsertFunction
    public TableFunction InsertFunction
    {
      get;
      protected set;
    }
    #endregion

    #region UpdateFunction
    public TableFunction UpdateFunction
    {
      get;
      protected set;
    }
    #endregion

    #region DeleteFunction
    public TableFunction DeleteFunction
    {
      get;
      protected set;
    }
    #endregion

    // Private Methods

    #region LoadFromXmlNode(XmlNode node)
    private void LoadFromXmlNode(XmlNode node)
    {
      Name = XmlUtil.GetAttribOrThrow(node, "Name");
      Member = XmlUtil.GetAttrib(node, "Member", "");
      AccessModifier = AccessModifier.Parse(XmlUtil.GetAttrib(node, "AccessModifier", ""));
      Modifier = MemberModifier.Parse(XmlUtil.GetAttrib(node, "Modifier", ""));

      ParseNodes(node);
    }
    #endregion

    #region ParseSection1Nodes(XmlNode parent, ref IEnumerator enumerator, ref bool more)
    private void ParseSection1Nodes(XmlNode parent, ref IEnumerator enumerator, ref bool more)
    {
      for (bool done=false; more && !done;)
      {
        XmlNode node = enumerator.Current as XmlNode;

        switch (node.Name.ToLower())
        {
          case "type":
            Type = new Type(node);
            break;

          case "insertfunction":
            InsertFunction = new TableFunction(node);
            break;

          case "updatefunction":
            UpdateFunction = new TableFunction(node);
            break;

          case "deletefunction":
            DeleteFunction = new TableFunction(node);
            break;

          default:
            done = true;
            break;
        }

        if (!done)
          more = enumerator.MoveNext();
      }
    }
    #endregion

    #region ParseNodes(XmlNode parent)
    private void ParseNodes(XmlNode parent)
    {
      IEnumerator enumerator = parent.ChildNodes.GetEnumerator();
      bool more = enumerator.MoveNext();
      ParseSection1Nodes(parent, ref enumerator, ref more);
    }
    #endregion
  }

  public partial class Type
  {
    // Constructors

    #region Type(string filename)
    public Type(string filename)
    {
      XmlDocument xml = new XmlDocument();
      xml.Load(filename);
      LoadFromXmlNode(xml.DocumentElement);
    }
    #endregion

    #region Type(XmlDocument xml)
    public Type(XmlDocument xml)
    {
      LoadFromXmlNode(xml.DocumentElement);
    }
    #endregion

    #region Type(XmlNode node)
    public Type(XmlNode node)
    {
      LoadFromXmlNode(node);
    }
    #endregion

    // Public Properties

    #region IdRef
    public Int64 IdRef
    {
      get;
      protected set;
    }
    #endregion

    #region Id
    public Int64 Id
    {
      get;
      protected set;
    }
    #endregion

    #region Name
    public string Name
    {
      get;
      protected set;
    }
    #endregion

    #region InheritanceCode
    public string InheritanceCode
    {
      get;
      protected set;
    }
    #endregion

    #region IsInheritanceDefault
    public bool IsInheritanceDefault
    {
      get;
      protected set;
    }
    #endregion

    #region AccessModifier
    public AccessModifier AccessModifier
    {
      get;
      protected set;
    }
    #endregion

    #region Modifier
    public ClassModifier Modifier
    {
      get;
      protected set;
    }
    #endregion

    #region Columns
    public List<Column> Columns
    {
      get
      {
        if (_columns == null)
          _columns = new List<Column>();

        return _columns;
      }
      protected set
      {
        _columns = value;
      }
    }
    private List<Column> _columns = null;
    #endregion

    #region Associations
    public List<Association> Associations
    {
      get
      {
        if (_associations == null)
          _associations = new List<Association>();

        return _associations;
      }
      protected set
      {
        _associations = value;
      }
    }
    private List<Association> _associations = null;
    #endregion

    #region Types
    public List<Type> Types
    {
      get
      {
        if (_types == null)
          _types = new List<Type>();

        return _types;
      }
      protected set
      {
        _types = value;
      }
    }
    private List<Type> _types = null;
    #endregion

    // Private Methods

    #region LoadFromXmlNode(XmlNode node)
    private void LoadFromXmlNode(XmlNode node)
    {
      IdRef = XmlUtil.GetInt64Attrib(node, "IdRef", 0);
      Id = XmlUtil.GetInt64Attrib(node, "Id", 0);
      Name = XmlUtil.GetAttrib(node, "Name", "");
      InheritanceCode = XmlUtil.GetAttrib(node, "InheritanceCode", "");
      IsInheritanceDefault = XmlUtil.GetBoolAttrib(node, "IsInheritanceDefault", false);
      AccessModifier = AccessModifier.Parse(XmlUtil.GetAttrib(node, "AccessModifier", ""));
      Modifier = ClassModifier.Parse(XmlUtil.GetAttrib(node, "Modifier", ""));

      ParseNodes(node);
    }
    #endregion

    #region ParseSection1Nodes(XmlNode parent, ref IEnumerator enumerator, ref bool more)
    private void ParseSection1Nodes(XmlNode parent, ref IEnumerator enumerator, ref bool more)
    {
      int seqState = 0;

      for (bool done=false; more && !done;)
      {
        XmlNode node = enumerator.Current as XmlNode;

        switch (node.Name.ToLower())
        {
          case "column":
          case "association":
            if (seqState > 0)
              throw new Exception("Elements out of sequence");

            seqState = 0;
            ParseSection2Nodes(parent, ref enumerator, ref more);
            break;

          case "type":
            if (seqState > 1)
              throw new Exception("Elements out of sequence");

            seqState = 1;

            Type elemType = new Type(node);
            if (elemType != null)
              Types.Add(elemType);
            break;

          default:
            done = true;
            break;
        }

        if (!done)
          more = enumerator.MoveNext();
      }
    }
    #endregion

    #region ParseSection2Nodes(XmlNode parent, ref IEnumerator enumerator, ref bool more)
    private void ParseSection2Nodes(XmlNode parent, ref IEnumerator enumerator, ref bool more)
    {
      int choice = -1;

      for (bool done=false; more && !done;)
      {
        XmlNode node = enumerator.Current as XmlNode;

        switch (node.Name.ToLower())
        {
          case "column":
            if (choice >= 0 && choice != 0)
              throw new Exception("Multiple elements matching a schema choice");

            choice = 0;

            Column elemColumn = new Column(node);
            if (elemColumn != null)
              Columns.Add(elemColumn);
            break;

          case "association":
            if (choice >= 0 && choice != 1)
              throw new Exception("Multiple elements matching a schema choice");

            choice = 1;

            Association elemAssociation = new Association(node);
            if (elemAssociation != null)
              Associations.Add(elemAssociation);
            break;

          default:
            done = true;
            break;
        }

        if (!done)
          more = enumerator.MoveNext();
      }
    }
    #endregion

    #region ParseNodes(XmlNode parent)
    private void ParseNodes(XmlNode parent)
    {
      IEnumerator enumerator = parent.ChildNodes.GetEnumerator();
      bool more = enumerator.MoveNext();
      ParseSection1Nodes(parent, ref enumerator, ref more);
    }
    #endregion
  }

  public partial class Column
  {
    // Constructors

    #region Column(string filename)
    public Column(string filename)
    {
      XmlDocument xml = new XmlDocument();
      xml.Load(filename);
      LoadFromXmlNode(xml.DocumentElement);
    }
    #endregion

    #region Column(XmlDocument xml)
    public Column(XmlDocument xml)
    {
      LoadFromXmlNode(xml.DocumentElement);
    }
    #endregion

    #region Column(XmlNode node)
    public Column(XmlNode node)
    {
      LoadFromXmlNode(node);
    }
    #endregion

    // Public Properties

    #region Name
    public string Name
    {
      get;
      protected set;
    }
    #endregion

    #region Member
    public string Member
    {
      get;
      protected set;
    }
    #endregion

    #region Storage
    public string Storage
    {
      get;
      protected set;
    }
    #endregion

    #region AccessModifier
    public AccessModifier AccessModifier
    {
      get;
      protected set;
    }
    #endregion

    #region Modifier
    public MemberModifier Modifier
    {
      get;
      protected set;
    }
    #endregion

    #region Type
    public string Type
    {
      get;
      protected set;
    }
    #endregion

    #region DbType
    public string DbType
    {
      get;
      protected set;
    }
    #endregion

    #region IsReadOnly
    public bool IsReadOnly
    {
      get;
      protected set;
    }
    #endregion

    #region IsPrimaryKey
    public bool IsPrimaryKey
    {
      get;
      protected set;
    }
    #endregion

    #region IsDbGenerated
    public bool IsDbGenerated
    {
      get;
      protected set;
    }
    #endregion

    #region CanBeNull
    public bool CanBeNull
    {
      get;
      protected set;
    }
    #endregion

    #region UpdateCheck
    public UpdateCheck UpdateCheck
    {
      get;
      protected set;
    }
    #endregion

    #region IsDiscriminator
    public bool IsDiscriminator
    {
      get;
      protected set;
    }
    #endregion

    #region Expression
    public string Expression
    {
      get;
      protected set;
    }
    #endregion

    #region IsVersion
    public bool IsVersion
    {
      get;
      protected set;
    }
    #endregion

    #region IsDelayLoaded
    public bool IsDelayLoaded
    {
      get;
      protected set;
    }
    #endregion

    #region AutoSync
    public AutoSync AutoSync
    {
      get;
      protected set;
    }
    #endregion

    // Private Methods

    #region LoadFromXmlNode(XmlNode node)
    private void LoadFromXmlNode(XmlNode node)
    {
      Name = XmlUtil.GetAttrib(node, "Name", "");
      Member = XmlUtil.GetAttrib(node, "Member", "");
      Storage = XmlUtil.GetAttrib(node, "Storage", "");
      AccessModifier = AccessModifier.Parse(XmlUtil.GetAttrib(node, "AccessModifier", ""));
      Modifier = MemberModifier.Parse(XmlUtil.GetAttrib(node, "Modifier", ""));
      Type = XmlUtil.GetAttribOrThrow(node, "Type");
      DbType = XmlUtil.GetAttrib(node, "DbType", "");
      IsReadOnly = XmlUtil.GetBoolAttrib(node, "IsReadOnly", false);
      IsPrimaryKey = XmlUtil.GetBoolAttrib(node, "IsPrimaryKey", false);
      IsDbGenerated = XmlUtil.GetBoolAttrib(node, "IsDbGenerated", false);
      CanBeNull = XmlUtil.GetBoolAttrib(node, "CanBeNull", false);
      UpdateCheck = UpdateCheck.Parse(XmlUtil.GetAttrib(node, "UpdateCheck", ""));
      IsDiscriminator = XmlUtil.GetBoolAttrib(node, "IsDiscriminator", false);
      Expression = XmlUtil.GetAttrib(node, "Expression", "");
      IsVersion = XmlUtil.GetBoolAttrib(node, "IsVersion", false);
      IsDelayLoaded = XmlUtil.GetBoolAttrib(node, "IsDelayLoaded", false);
      AutoSync = AutoSync.Parse(XmlUtil.GetAttrib(node, "AutoSync", ""));

      ParseNodes(node);
    }
    #endregion

    #region ParseNodes(XmlNode parent)
    private void ParseNodes(XmlNode parent)
    {
    }
    #endregion
  }

  public partial class Association
  {
    // Constructors

    #region Association(string filename)
    public Association(string filename)
    {
      XmlDocument xml = new XmlDocument();
      xml.Load(filename);
      LoadFromXmlNode(xml.DocumentElement);
    }
    #endregion

    #region Association(XmlDocument xml)
    public Association(XmlDocument xml)
    {
      LoadFromXmlNode(xml.DocumentElement);
    }
    #endregion

    #region Association(XmlNode node)
    public Association(XmlNode node)
    {
      LoadFromXmlNode(node);
    }
    #endregion

    // Public Properties

    #region Name
    public string Name
    {
      get;
      protected set;
    }
    #endregion

    #region Member
    public string Member
    {
      get;
      protected set;
    }
    #endregion

    #region Storage
    public string Storage
    {
      get;
      protected set;
    }
    #endregion

    #region AccessModifier
    public AccessModifier AccessModifier
    {
      get;
      protected set;
    }
    #endregion

    #region Modifier
    public MemberModifier Modifier
    {
      get;
      protected set;
    }
    #endregion

    #region Type
    public string Type
    {
      get;
      protected set;
    }
    #endregion

    #region ThisKey
    public string ThisKey
    {
      get;
      protected set;
    }
    #endregion

    #region OtherKey
    public string OtherKey
    {
      get;
      protected set;
    }
    #endregion

    #region IsForeignKey
    public bool IsForeignKey
    {
      get;
      protected set;
    }
    #endregion

    #region Cardinality
    public Cardinality Cardinality
    {
      get;
      protected set;
    }
    #endregion

    #region DeleteRule
    public string DeleteRule
    {
      get;
      protected set;
    }
    #endregion

    #region DeleteOnNull
    public bool DeleteOnNull
    {
      get;
      protected set;
    }
    #endregion

    // Private Methods

    #region LoadFromXmlNode(XmlNode node)
    private void LoadFromXmlNode(XmlNode node)
    {
      Name = XmlUtil.GetAttribOrThrow(node, "Name");
      Member = XmlUtil.GetAttribOrThrow(node, "Member");
      Storage = XmlUtil.GetAttrib(node, "Storage", "");
      AccessModifier = AccessModifier.Parse(XmlUtil.GetAttrib(node, "AccessModifier", ""));
      Modifier = MemberModifier.Parse(XmlUtil.GetAttrib(node, "Modifier", ""));
      Type = XmlUtil.GetAttribOrThrow(node, "Type");
      ThisKey = XmlUtil.GetAttrib(node, "ThisKey", "");
      OtherKey = XmlUtil.GetAttrib(node, "OtherKey", "");
      IsForeignKey = XmlUtil.GetBoolAttrib(node, "IsForeignKey", false);
      Cardinality = Cardinality.Parse(XmlUtil.GetAttrib(node, "Cardinality", ""));
      DeleteRule = XmlUtil.GetAttrib(node, "DeleteRule", "");
      DeleteOnNull = XmlUtil.GetBoolAttrib(node, "DeleteOnNull", false);

      ParseNodes(node);
    }
    #endregion

    #region ParseNodes(XmlNode parent)
    private void ParseNodes(XmlNode parent)
    {
    }
    #endregion
  }

  public partial class Function
  {
    // Constructors

    #region Function(string filename)
    public Function(string filename)
    {
      XmlDocument xml = new XmlDocument();
      xml.Load(filename);
      LoadFromXmlNode(xml.DocumentElement);
    }
    #endregion

    #region Function(XmlDocument xml)
    public Function(XmlDocument xml)
    {
      LoadFromXmlNode(xml.DocumentElement);
    }
    #endregion

    #region Function(XmlNode node)
    public Function(XmlNode node)
    {
      LoadFromXmlNode(node);
    }
    #endregion

    // Public Properties

    #region Name
    public string Name
    {
      get;
      protected set;
    }
    #endregion

    #region Id
    public Int64 Id
    {
      get;
      protected set;
    }
    #endregion

    #region Method
    public string Method
    {
      get;
      protected set;
    }
    #endregion

    #region AccessModifier
    public AccessModifier AccessModifier
    {
      get;
      protected set;
    }
    #endregion

    #region Modifier
    public MemberModifier Modifier
    {
      get;
      protected set;
    }
    #endregion

    #region HasMultipleResults
    public bool HasMultipleResults
    {
      get;
      protected set;
    }
    #endregion

    #region IsComposable
    public bool IsComposable
    {
      get;
      protected set;
    }
    #endregion

    #region Parameters
    public List<Parameter> Parameters
    {
      get
      {
        if (_parameters == null)
          _parameters = new List<Parameter>();

        return _parameters;
      }
      protected set
      {
        _parameters = value;
      }
    }
    private List<Parameter> _parameters = null;
    #endregion

    #region ElementTypes
    public List<Type> ElementTypes
    {
      get
      {
        if (_elementTypes == null)
          _elementTypes = new List<Type>();

        return _elementTypes;
      }
      protected set
      {
        _elementTypes = value;
      }
    }
    private List<Type> _elementTypes = null;
    #endregion

    #region Return
    public Return Return
    {
      get;
      protected set;
    }
    #endregion

    // Private Methods

    #region LoadFromXmlNode(XmlNode node)
    private void LoadFromXmlNode(XmlNode node)
    {
      Name = XmlUtil.GetAttribOrThrow(node, "Name");
      Id = XmlUtil.GetInt64Attrib(node, "Id", 0);
      Method = XmlUtil.GetAttrib(node, "Method", "");
      AccessModifier = AccessModifier.Parse(XmlUtil.GetAttrib(node, "AccessModifier", ""));
      Modifier = MemberModifier.Parse(XmlUtil.GetAttrib(node, "Modifier", ""));
      HasMultipleResults = XmlUtil.GetBoolAttrib(node, "HasMultipleResults", false);
      IsComposable = XmlUtil.GetBoolAttrib(node, "IsComposable", false);

      ParseNodes(node);
    }
    #endregion

    #region ParseSection1Nodes(XmlNode parent, ref IEnumerator enumerator, ref bool more)
    private void ParseSection1Nodes(XmlNode parent, ref IEnumerator enumerator, ref bool more)
    {
      int seqState = 0;

      for (bool done=false; more && !done;)
      {
        XmlNode node = enumerator.Current as XmlNode;

        switch (node.Name.ToLower())
        {
          case "parameter":
            if (seqState > 0)
              throw new Exception("Elements out of sequence");

            seqState = 0;

            Parameter elemParameter = new Parameter(node);
            if (elemParameter != null)
              Parameters.Add(elemParameter);
            break;

          case "elementtype":
          case "return":
            if (seqState > 2)
              throw new Exception("Elements out of sequence");

            seqState = 2;
            ParseSection3Nodes(parent, ref enumerator, ref more);
            break;

          default:
            done = true;
            break;
        }

        if (!done)
          more = enumerator.MoveNext();
      }
    }
    #endregion

    #region ParseSection3Nodes(XmlNode parent, ref IEnumerator enumerator, ref bool more)
    private void ParseSection3Nodes(XmlNode parent, ref IEnumerator enumerator, ref bool more)
    {
      int choice = -1;

      for (bool done=false; more && !done;)
      {
        XmlNode node = enumerator.Current as XmlNode;

        switch (node.Name.ToLower())
        {
          case "elementtype":
            if (choice >= 0 && choice != 0)
              throw new Exception("Multiple elements matching a schema choice");

            choice = 0;

            Type elemElementType = new Type(node);
            if (elemElementType != null)
              ElementTypes.Add(elemElementType);
            break;

          case "return":
            if (choice >= 0 && choice != 1)
              throw new Exception("Multiple elements matching a schema choice");

            choice = 1;
            Return = new Return(node);
            break;

          default:
            done = true;
            break;
        }

        if (!done)
          more = enumerator.MoveNext();
      }
    }
    #endregion

    #region ParseNodes(XmlNode parent)
    private void ParseNodes(XmlNode parent)
    {
      IEnumerator enumerator = parent.ChildNodes.GetEnumerator();
      bool more = enumerator.MoveNext();
      ParseSection1Nodes(parent, ref enumerator, ref more);
    }
    #endregion
  }

  public partial class TableFunction
  {
    // Constructors

    #region TableFunction(string filename)
    public TableFunction(string filename)
    {
      XmlDocument xml = new XmlDocument();
      xml.Load(filename);
      LoadFromXmlNode(xml.DocumentElement);
    }
    #endregion

    #region TableFunction(XmlDocument xml)
    public TableFunction(XmlDocument xml)
    {
      LoadFromXmlNode(xml.DocumentElement);
    }
    #endregion

    #region TableFunction(XmlNode node)
    public TableFunction(XmlNode node)
    {
      LoadFromXmlNode(node);
    }
    #endregion

    // Public Properties

    #region FunctionId
    public Int64 FunctionId
    {
      get;
      protected set;
    }
    #endregion

    #region AccessModifier
    public AccessModifier AccessModifier
    {
      get;
      protected set;
    }
    #endregion

    #region Arguments
    public List<TableFunctionParameter> Arguments
    {
      get
      {
        if (_arguments == null)
          _arguments = new List<TableFunctionParameter>();

        return _arguments;
      }
      protected set
      {
        _arguments = value;
      }
    }
    private List<TableFunctionParameter> _arguments = null;
    #endregion

    #region Return
    public TableFunctionReturn Return
    {
      get;
      protected set;
    }
    #endregion

    // Private Methods

    #region LoadFromXmlNode(XmlNode node)
    private void LoadFromXmlNode(XmlNode node)
    {
      FunctionId = XmlUtil.GetInt64AttribOrThrow(node, "FunctionId");
      AccessModifier = AccessModifier.Parse(XmlUtil.GetAttrib(node, "AccessModifier", ""));

      ParseNodes(node);
    }
    #endregion

    #region ParseSection1Nodes(XmlNode parent, ref IEnumerator enumerator, ref bool more)
    private void ParseSection1Nodes(XmlNode parent, ref IEnumerator enumerator, ref bool more)
    {
      int seqState = 0;

      for (bool done=false; more && !done;)
      {
        XmlNode node = enumerator.Current as XmlNode;

        switch (node.Name.ToLower())
        {
          case "argument":
            if (seqState > 0)
              throw new Exception("Elements out of sequence");

            seqState = 0;

            TableFunctionParameter elemArgument = new TableFunctionParameter(node);
            if (elemArgument != null)
              Arguments.Add(elemArgument);
            break;

          case "return":
            if (seqState > 1)
              throw new Exception("Elements out of sequence");

            seqState = 1;
            Return = new TableFunctionReturn(node);
            break;

          default:
            done = true;
            break;
        }

        if (!done)
          more = enumerator.MoveNext();
      }
    }
    #endregion

    #region ParseNodes(XmlNode parent)
    private void ParseNodes(XmlNode parent)
    {
      IEnumerator enumerator = parent.ChildNodes.GetEnumerator();
      bool more = enumerator.MoveNext();
      ParseSection1Nodes(parent, ref enumerator, ref more);
    }
    #endregion
  }

  public partial class Parameter
  {
    // Constructors

    #region Parameter(string filename)
    public Parameter(string filename)
    {
      XmlDocument xml = new XmlDocument();
      xml.Load(filename);
      LoadFromXmlNode(xml.DocumentElement);
    }
    #endregion

    #region Parameter(XmlDocument xml)
    public Parameter(XmlDocument xml)
    {
      LoadFromXmlNode(xml.DocumentElement);
    }
    #endregion

    #region Parameter(XmlNode node)
    public Parameter(XmlNode node)
    {
      LoadFromXmlNode(node);
    }
    #endregion

    // Public Properties

    #region Name
    public string Name
    {
      get;
      protected set;
    }
    #endregion

    #region InnerParameter
    public string InnerParameter
    {
      get;
      protected set;
    }
    #endregion

    #region Type
    public string Type
    {
      get;
      protected set;
    }
    #endregion

    #region DbType
    public string DbType
    {
      get;
      protected set;
    }
    #endregion

    #region Direction
    public ParameterDirection Direction
    {
      get;
      protected set;
    }
    #endregion

    // Private Methods

    #region LoadFromXmlNode(XmlNode node)
    private void LoadFromXmlNode(XmlNode node)
    {
      Name = XmlUtil.GetAttribOrThrow(node, "Name");
      InnerParameter = XmlUtil.GetAttrib(node, "Parameter", "");
      Type = XmlUtil.GetAttribOrThrow(node, "Type");
      DbType = XmlUtil.GetAttrib(node, "DbType", "");
      Direction = ParameterDirection.Parse(XmlUtil.GetAttrib(node, "Direction", ""));

      ParseNodes(node);
    }
    #endregion

    #region ParseNodes(XmlNode parent)
    private void ParseNodes(XmlNode parent)
    {
    }
    #endregion
  }

  public partial class Return
  {
    // Constructors

    #region Return(string filename)
    public Return(string filename)
    {
      XmlDocument xml = new XmlDocument();
      xml.Load(filename);
      LoadFromXmlNode(xml.DocumentElement);
    }
    #endregion

    #region Return(XmlDocument xml)
    public Return(XmlDocument xml)
    {
      LoadFromXmlNode(xml.DocumentElement);
    }
    #endregion

    #region Return(XmlNode node)
    public Return(XmlNode node)
    {
      LoadFromXmlNode(node);
    }
    #endregion

    // Public Properties

    #region Type
    public string Type
    {
      get;
      protected set;
    }
    #endregion

    #region DbType
    public string DbType
    {
      get;
      protected set;
    }
    #endregion

    // Private Methods

    #region LoadFromXmlNode(XmlNode node)
    private void LoadFromXmlNode(XmlNode node)
    {
      Type = XmlUtil.GetAttribOrThrow(node, "Type");
      DbType = XmlUtil.GetAttrib(node, "DbType", "");

      ParseNodes(node);
    }
    #endregion

    #region ParseNodes(XmlNode parent)
    private void ParseNodes(XmlNode parent)
    {
    }
    #endregion
  }

  public partial class TableFunctionParameter
  {
    // Constructors

    #region TableFunctionParameter(string filename)
    public TableFunctionParameter(string filename)
    {
      XmlDocument xml = new XmlDocument();
      xml.Load(filename);
      LoadFromXmlNode(xml.DocumentElement);
    }
    #endregion

    #region TableFunctionParameter(XmlDocument xml)
    public TableFunctionParameter(XmlDocument xml)
    {
      LoadFromXmlNode(xml.DocumentElement);
    }
    #endregion

    #region TableFunctionParameter(XmlNode node)
    public TableFunctionParameter(XmlNode node)
    {
      LoadFromXmlNode(node);
    }
    #endregion

    // Public Properties

    #region Parameter
    public string Parameter
    {
      get;
      protected set;
    }
    #endregion

    #region Member
    public string Member
    {
      get;
      protected set;
    }
    #endregion

    #region Version
    public Version Version
    {
      get;
      protected set;
    }
    #endregion

    // Private Methods

    #region LoadFromXmlNode(XmlNode node)
    private void LoadFromXmlNode(XmlNode node)
    {
      Parameter = XmlUtil.GetAttribOrThrow(node, "Parameter");
      Member = XmlUtil.GetAttribOrThrow(node, "Member");
      Version = Version.Parse(XmlUtil.GetAttrib(node, "Version", ""));

      ParseNodes(node);
    }
    #endregion

    #region ParseNodes(XmlNode parent)
    private void ParseNodes(XmlNode parent)
    {
    }
    #endregion
  }

  public partial class TableFunctionReturn
  {
    // Constructors

    #region TableFunctionReturn(string filename)
    public TableFunctionReturn(string filename)
    {
      XmlDocument xml = new XmlDocument();
      xml.Load(filename);
      LoadFromXmlNode(xml.DocumentElement);
    }
    #endregion

    #region TableFunctionReturn(XmlDocument xml)
    public TableFunctionReturn(XmlDocument xml)
    {
      LoadFromXmlNode(xml.DocumentElement);
    }
    #endregion

    #region TableFunctionReturn(XmlNode node)
    public TableFunctionReturn(XmlNode node)
    {
      LoadFromXmlNode(node);
    }
    #endregion

    // Public Properties

    #region Member
    public string Member
    {
      get;
      protected set;
    }
    #endregion

    // Private Methods

    #region LoadFromXmlNode(XmlNode node)
    private void LoadFromXmlNode(XmlNode node)
    {
      Member = XmlUtil.GetAttribOrThrow(node, "Member");

      ParseNodes(node);
    }
    #endregion

    #region ParseNodes(XmlNode parent)
    private void ParseNodes(XmlNode parent)
    {
    }
    #endregion
  }

  public partial class Connection
  {
    // Constructors

    #region Connection(string filename)
    public Connection(string filename)
    {
      XmlDocument xml = new XmlDocument();
      xml.Load(filename);
      LoadFromXmlNode(xml.DocumentElement);
    }
    #endregion

    #region Connection(XmlDocument xml)
    public Connection(XmlDocument xml)
    {
      LoadFromXmlNode(xml.DocumentElement);
    }
    #endregion

    #region Connection(XmlNode node)
    public Connection(XmlNode node)
    {
      LoadFromXmlNode(node);
    }
    #endregion

    // Public Properties

    #region Provider
    public string Provider
    {
      get;
      protected set;
    }
    #endregion

    #region Mode
    public ConnectionMode Mode
    {
      get;
      protected set;
    }
    #endregion

    #region ConnectionString
    public string ConnectionString
    {
      get;
      protected set;
    }
    #endregion

    #region SettingsObjectName
    public string SettingsObjectName
    {
      get;
      protected set;
    }
    #endregion

    #region SettingsPropertyName
    public string SettingsPropertyName
    {
      get;
      protected set;
    }
    #endregion

    // Private Methods

    #region LoadFromXmlNode(XmlNode node)
    private void LoadFromXmlNode(XmlNode node)
    {
      Provider = XmlUtil.GetAttribOrThrow(node, "Provider");
      Mode = ConnectionMode.Parse(XmlUtil.GetAttrib(node, "Mode", ""));
      ConnectionString = XmlUtil.GetAttrib(node, "ConnectionString", "");
      SettingsObjectName = XmlUtil.GetAttrib(node, "SettingsObjectName", "");
      SettingsPropertyName = XmlUtil.GetAttrib(node, "SettingsPropertyName", "");

      ParseNodes(node);
    }
    #endregion

    #region ParseNodes(XmlNode parent)
    private void ParseNodes(XmlNode parent)
    {
    }
    #endregion
  }

  public class ConnectionMode
  {
    // Public Constants

    #region Public Constants
    public const int ConnectionStringVal = 1;
    public const int AppSettingsVal = 2;
    public const int WebSettingsVal = 3;

    public static readonly ConnectionMode Unknown = new ConnectionMode("Unknown", 0);
    public static readonly ConnectionMode ConnectionString = new ConnectionMode("ConnectionString", ConnectionStringVal);
    public static readonly ConnectionMode AppSettings = new ConnectionMode("AppSettings", AppSettingsVal);
    public static readonly ConnectionMode WebSettings = new ConnectionMode("WebSettings", WebSettingsVal);
    #endregion

    // Public Constructors

    #region ConnectionMode(string text, int val)
    public ConnectionMode(string text, int val)
    {
      Text = text;
      Value = val;
    }
    #endregion

    // Public Properties

    #region Text
    public string Text
    {
      get;
      protected set;
    }
    #endregion

    #region Value
    public int Value
    {
      get;
      protected set;
    }
    #endregion

    // Public Methods

    #region ToString()
    public override string ToString()
    {
      return Text;
    }
    #endregion

    #region GetHashCode()
    public override int GetHashCode()
    {
      return Value;
    }
    #endregion

    #region Equals(object o)
    public override bool Equals(object o)
    {
      if (o.GetType() == typeof(int))
        return this.Value == (int) o;

      if (o.GetType() == typeof(string))
        return this.Text == (string) o;

      if (o.GetType() == typeof(ConnectionMode))
        return this.Value == ((ConnectionMode) o).Value;

      return false;
    }
    #endregion

    // Public Static Methods

    #region Parse(string text)
    public static ConnectionMode Parse(string text)
    {
      if (text == null)
        return Unknown;

      switch (text.ToLower())
      {
        case "connectionstring":
          return ConnectionString;

        case "appsettings":
          return AppSettings;

        case "websettings":
          return WebSettings;

        default:
          return Unknown;
      }
    }
    #endregion

    #region Find(string text)
    public static ConnectionMode Find(string text)
    {
      return Parse(text);
    }
    #endregion

    #region Find(int val)
    public static ConnectionMode Find(int val)
    {
      switch (val)
      {
        case 1:
          return ConnectionString;

        case 2:
          return AppSettings;

        case 3:
          return WebSettings;

        default:
          return Unknown;
      }
    }
    #endregion

    // Public Operators

    #region operator ConnectionMode(int val)
    public static implicit operator ConnectionMode(int val)
    {
      return Find(val);
    }
    #endregion

    #region operator ConnectionMode(string val)
    public static implicit operator ConnectionMode(string val)
    {
      return Find(val);
    }
    #endregion

    #region operator int(ConnectionMode val)
    public static implicit operator int(ConnectionMode val)
    {
      return val.Value;
    }
    #endregion

    #region operator string(ConnectionMode val)
    public static implicit operator string(ConnectionMode val)
    {
      return val.Text;
    }
    #endregion

    #region operator ==(ConnectionMode lhs, ConnectionMode rhs)
    public static bool operator ==(ConnectionMode lhs, ConnectionMode rhs)
    {
      return lhs.Value == rhs.Value;
    }
    #endregion

    #region operator !=(ConnectionMode lhs, ConnectionMode rhs)
    public static bool operator !=(ConnectionMode lhs, ConnectionMode rhs)
    {
      return lhs.Value != rhs.Value;
    }
    #endregion

    #region operator ==(ConnectionMode lhs, int rhs)
    public static bool operator ==(ConnectionMode lhs, int rhs)
    {
      return lhs.Value == rhs;
    }
    #endregion

    #region operator !=(ConnectionMode lhs, int rhs)
    public static bool operator !=(ConnectionMode lhs, int rhs)
    {
      return lhs.Value != rhs;
    }
    #endregion

    #region operator ==(ConnectionMode lhs, string rhs)
    public static bool operator ==(ConnectionMode lhs, string rhs)
    {
      return lhs.Text.ToLower() == rhs.ToLower();
    }
    #endregion

    #region operator !=(ConnectionMode lhs, string rhs)
    public static bool operator !=(ConnectionMode lhs, string rhs)
    {
      return lhs.Text.ToLower() != rhs.ToLower();
    }
    #endregion
  }

  public class AccessModifier
  {
    // Public Constants

    #region Public Constants
    public const int PublicVal = 1;
    public const int InternalVal = 2;
    public const int ProtectedVal = 3;
    public const int ProtectedInternalVal = 4;
    public const int PrivateVal = 5;

    public static readonly AccessModifier Unknown = new AccessModifier("Unknown", 0);
    public static readonly AccessModifier Public = new AccessModifier("Public", PublicVal);
    public static readonly AccessModifier Internal = new AccessModifier("Internal", InternalVal);
    public static readonly AccessModifier Protected = new AccessModifier("Protected", ProtectedVal);
    public static readonly AccessModifier ProtectedInternal = new AccessModifier("ProtectedInternal", ProtectedInternalVal);
    public static readonly AccessModifier Private = new AccessModifier("Private", PrivateVal);
    #endregion

    // Public Constructors

    #region AccessModifier(string text, int val)
    public AccessModifier(string text, int val)
    {
      Text = text;
      Value = val;
    }
    #endregion

    // Public Properties

    #region Text
    public string Text
    {
      get;
      protected set;
    }
    #endregion

    #region Value
    public int Value
    {
      get;
      protected set;
    }
    #endregion

    // Public Methods

    #region ToString()
    public override string ToString()
    {
      return Text;
    }
    #endregion

    #region GetHashCode()
    public override int GetHashCode()
    {
      return Value;
    }
    #endregion

    #region Equals(object o)
    public override bool Equals(object o)
    {
      if (o.GetType() == typeof(int))
        return this.Value == (int) o;

      if (o.GetType() == typeof(string))
        return this.Text == (string) o;

      if (o.GetType() == typeof(AccessModifier))
        return this.Value == ((AccessModifier) o).Value;

      return false;
    }
    #endregion

    // Public Static Methods

    #region Parse(string text)
    public static AccessModifier Parse(string text)
    {
      if (text == null)
        return Unknown;

      switch (text.ToLower())
      {
        case "public":
          return Public;

        case "internal":
          return Internal;

        case "protected":
          return Protected;

        case "protectedinternal":
          return ProtectedInternal;

        case "private":
          return Private;

        default:
          return Unknown;
      }
    }
    #endregion

    #region Find(string text)
    public static AccessModifier Find(string text)
    {
      return Parse(text);
    }
    #endregion

    #region Find(int val)
    public static AccessModifier Find(int val)
    {
      switch (val)
      {
        case 1:
          return Public;

        case 2:
          return Internal;

        case 3:
          return Protected;

        case 4:
          return ProtectedInternal;

        case 5:
          return Private;

        default:
          return Unknown;
      }
    }
    #endregion

    // Public Operators

    #region operator AccessModifier(int val)
    public static implicit operator AccessModifier(int val)
    {
      return Find(val);
    }
    #endregion

    #region operator AccessModifier(string val)
    public static implicit operator AccessModifier(string val)
    {
      return Find(val);
    }
    #endregion

    #region operator int(AccessModifier val)
    public static implicit operator int(AccessModifier val)
    {
      return val.Value;
    }
    #endregion

    #region operator string(AccessModifier val)
    public static implicit operator string(AccessModifier val)
    {
      return val.Text;
    }
    #endregion

    #region operator ==(AccessModifier lhs, AccessModifier rhs)
    public static bool operator ==(AccessModifier lhs, AccessModifier rhs)
    {
      return lhs.Value == rhs.Value;
    }
    #endregion

    #region operator !=(AccessModifier lhs, AccessModifier rhs)
    public static bool operator !=(AccessModifier lhs, AccessModifier rhs)
    {
      return lhs.Value != rhs.Value;
    }
    #endregion

    #region operator ==(AccessModifier lhs, int rhs)
    public static bool operator ==(AccessModifier lhs, int rhs)
    {
      return lhs.Value == rhs;
    }
    #endregion

    #region operator !=(AccessModifier lhs, int rhs)
    public static bool operator !=(AccessModifier lhs, int rhs)
    {
      return lhs.Value != rhs;
    }
    #endregion

    #region operator ==(AccessModifier lhs, string rhs)
    public static bool operator ==(AccessModifier lhs, string rhs)
    {
      return lhs.Text.ToLower() == rhs.ToLower();
    }
    #endregion

    #region operator !=(AccessModifier lhs, string rhs)
    public static bool operator !=(AccessModifier lhs, string rhs)
    {
      return lhs.Text.ToLower() != rhs.ToLower();
    }
    #endregion
  }

  public class UpdateCheck
  {
    // Public Constants

    #region Public Constants
    public const int AlwaysVal = 1;
    public const int NeverVal = 2;
    public const int WhenChangedVal = 3;

    public static readonly UpdateCheck Unknown = new UpdateCheck("Unknown", 0);
    public static readonly UpdateCheck Always = new UpdateCheck("Always", AlwaysVal);
    public static readonly UpdateCheck Never = new UpdateCheck("Never", NeverVal);
    public static readonly UpdateCheck WhenChanged = new UpdateCheck("WhenChanged", WhenChangedVal);
    #endregion

    // Public Constructors

    #region UpdateCheck(string text, int val)
    public UpdateCheck(string text, int val)
    {
      Text = text;
      Value = val;
    }
    #endregion

    // Public Properties

    #region Text
    public string Text
    {
      get;
      protected set;
    }
    #endregion

    #region Value
    public int Value
    {
      get;
      protected set;
    }
    #endregion

    // Public Methods

    #region ToString()
    public override string ToString()
    {
      return Text;
    }
    #endregion

    #region GetHashCode()
    public override int GetHashCode()
    {
      return Value;
    }
    #endregion

    #region Equals(object o)
    public override bool Equals(object o)
    {
      if (o.GetType() == typeof(int))
        return this.Value == (int) o;

      if (o.GetType() == typeof(string))
        return this.Text == (string) o;

      if (o.GetType() == typeof(UpdateCheck))
        return this.Value == ((UpdateCheck) o).Value;

      return false;
    }
    #endregion

    // Public Static Methods

    #region Parse(string text)
    public static UpdateCheck Parse(string text)
    {
      if (text == null)
        return Unknown;

      switch (text.ToLower())
      {
        case "always":
          return Always;

        case "never":
          return Never;

        case "whenchanged":
          return WhenChanged;

        default:
          return Unknown;
      }
    }
    #endregion

    #region Find(string text)
    public static UpdateCheck Find(string text)
    {
      return Parse(text);
    }
    #endregion

    #region Find(int val)
    public static UpdateCheck Find(int val)
    {
      switch (val)
      {
        case 1:
          return Always;

        case 2:
          return Never;

        case 3:
          return WhenChanged;

        default:
          return Unknown;
      }
    }
    #endregion

    // Public Operators

    #region operator UpdateCheck(int val)
    public static implicit operator UpdateCheck(int val)
    {
      return Find(val);
    }
    #endregion

    #region operator UpdateCheck(string val)
    public static implicit operator UpdateCheck(string val)
    {
      return Find(val);
    }
    #endregion

    #region operator int(UpdateCheck val)
    public static implicit operator int(UpdateCheck val)
    {
      return val.Value;
    }
    #endregion

    #region operator string(UpdateCheck val)
    public static implicit operator string(UpdateCheck val)
    {
      return val.Text;
    }
    #endregion

    #region operator ==(UpdateCheck lhs, UpdateCheck rhs)
    public static bool operator ==(UpdateCheck lhs, UpdateCheck rhs)
    {
      return lhs.Value == rhs.Value;
    }
    #endregion

    #region operator !=(UpdateCheck lhs, UpdateCheck rhs)
    public static bool operator !=(UpdateCheck lhs, UpdateCheck rhs)
    {
      return lhs.Value != rhs.Value;
    }
    #endregion

    #region operator ==(UpdateCheck lhs, int rhs)
    public static bool operator ==(UpdateCheck lhs, int rhs)
    {
      return lhs.Value == rhs;
    }
    #endregion

    #region operator !=(UpdateCheck lhs, int rhs)
    public static bool operator !=(UpdateCheck lhs, int rhs)
    {
      return lhs.Value != rhs;
    }
    #endregion

    #region operator ==(UpdateCheck lhs, string rhs)
    public static bool operator ==(UpdateCheck lhs, string rhs)
    {
      return lhs.Text.ToLower() == rhs.ToLower();
    }
    #endregion

    #region operator !=(UpdateCheck lhs, string rhs)
    public static bool operator !=(UpdateCheck lhs, string rhs)
    {
      return lhs.Text.ToLower() != rhs.ToLower();
    }
    #endregion
  }

  public class SerializationMode
  {
    // Public Constants

    #region Public Constants
    public const int NoneVal = 1;
    public const int UnidirectionalVal = 2;

    public static readonly SerializationMode Unknown = new SerializationMode("Unknown", 0);
    public static readonly SerializationMode None = new SerializationMode("None", NoneVal);
    public static readonly SerializationMode Unidirectional = new SerializationMode("Unidirectional", UnidirectionalVal);
    #endregion

    // Public Constructors

    #region SerializationMode(string text, int val)
    public SerializationMode(string text, int val)
    {
      Text = text;
      Value = val;
    }
    #endregion

    // Public Properties

    #region Text
    public string Text
    {
      get;
      protected set;
    }
    #endregion

    #region Value
    public int Value
    {
      get;
      protected set;
    }
    #endregion

    // Public Methods

    #region ToString()
    public override string ToString()
    {
      return Text;
    }
    #endregion

    #region GetHashCode()
    public override int GetHashCode()
    {
      return Value;
    }
    #endregion

    #region Equals(object o)
    public override bool Equals(object o)
    {
      if (o.GetType() == typeof(int))
        return this.Value == (int) o;

      if (o.GetType() == typeof(string))
        return this.Text == (string) o;

      if (o.GetType() == typeof(SerializationMode))
        return this.Value == ((SerializationMode) o).Value;

      return false;
    }
    #endregion

    // Public Static Methods

    #region Parse(string text)
    public static SerializationMode Parse(string text)
    {
      if (text == null)
        return Unknown;

      switch (text.ToLower())
      {
        case "none":
          return None;

        case "unidirectional":
          return Unidirectional;

        default:
          return Unknown;
      }
    }
    #endregion

    #region Find(string text)
    public static SerializationMode Find(string text)
    {
      return Parse(text);
    }
    #endregion

    #region Find(int val)
    public static SerializationMode Find(int val)
    {
      switch (val)
      {
        case 1:
          return None;

        case 2:
          return Unidirectional;

        default:
          return Unknown;
      }
    }
    #endregion

    // Public Operators

    #region operator SerializationMode(int val)
    public static implicit operator SerializationMode(int val)
    {
      return Find(val);
    }
    #endregion

    #region operator SerializationMode(string val)
    public static implicit operator SerializationMode(string val)
    {
      return Find(val);
    }
    #endregion

    #region operator int(SerializationMode val)
    public static implicit operator int(SerializationMode val)
    {
      return val.Value;
    }
    #endregion

    #region operator string(SerializationMode val)
    public static implicit operator string(SerializationMode val)
    {
      return val.Text;
    }
    #endregion

    #region operator ==(SerializationMode lhs, SerializationMode rhs)
    public static bool operator ==(SerializationMode lhs, SerializationMode rhs)
    {
      return lhs.Value == rhs.Value;
    }
    #endregion

    #region operator !=(SerializationMode lhs, SerializationMode rhs)
    public static bool operator !=(SerializationMode lhs, SerializationMode rhs)
    {
      return lhs.Value != rhs.Value;
    }
    #endregion

    #region operator ==(SerializationMode lhs, int rhs)
    public static bool operator ==(SerializationMode lhs, int rhs)
    {
      return lhs.Value == rhs;
    }
    #endregion

    #region operator !=(SerializationMode lhs, int rhs)
    public static bool operator !=(SerializationMode lhs, int rhs)
    {
      return lhs.Value != rhs;
    }
    #endregion

    #region operator ==(SerializationMode lhs, string rhs)
    public static bool operator ==(SerializationMode lhs, string rhs)
    {
      return lhs.Text.ToLower() == rhs.ToLower();
    }
    #endregion

    #region operator !=(SerializationMode lhs, string rhs)
    public static bool operator !=(SerializationMode lhs, string rhs)
    {
      return lhs.Text.ToLower() != rhs.ToLower();
    }
    #endregion
  }

  public class ParameterDirection
  {
    // Public Constants

    #region Public Constants
    public const int InVal = 1;
    public const int OutVal = 2;
    public const int InOutVal = 3;

    public static readonly ParameterDirection Unknown = new ParameterDirection("Unknown", 0);
    public static readonly ParameterDirection In = new ParameterDirection("In", InVal);
    public static readonly ParameterDirection Out = new ParameterDirection("Out", OutVal);
    public static readonly ParameterDirection InOut = new ParameterDirection("InOut", InOutVal);
    #endregion

    // Public Constructors

    #region ParameterDirection(string text, int val)
    public ParameterDirection(string text, int val)
    {
      Text = text;
      Value = val;
    }
    #endregion

    // Public Properties

    #region Text
    public string Text
    {
      get;
      protected set;
    }
    #endregion

    #region Value
    public int Value
    {
      get;
      protected set;
    }
    #endregion

    // Public Methods

    #region ToString()
    public override string ToString()
    {
      return Text;
    }
    #endregion

    #region GetHashCode()
    public override int GetHashCode()
    {
      return Value;
    }
    #endregion

    #region Equals(object o)
    public override bool Equals(object o)
    {
      if (o.GetType() == typeof(int))
        return this.Value == (int) o;

      if (o.GetType() == typeof(string))
        return this.Text == (string) o;

      if (o.GetType() == typeof(ParameterDirection))
        return this.Value == ((ParameterDirection) o).Value;

      return false;
    }
    #endregion

    // Public Static Methods

    #region Parse(string text)
    public static ParameterDirection Parse(string text)
    {
      if (text == null)
        return Unknown;

      switch (text.ToLower())
      {
        case "in":
          return In;

        case "out":
          return Out;

        case "inout":
          return InOut;

        default:
          return Unknown;
      }
    }
    #endregion

    #region Find(string text)
    public static ParameterDirection Find(string text)
    {
      return Parse(text);
    }
    #endregion

    #region Find(int val)
    public static ParameterDirection Find(int val)
    {
      switch (val)
      {
        case 1:
          return In;

        case 2:
          return Out;

        case 3:
          return InOut;

        default:
          return Unknown;
      }
    }
    #endregion

    // Public Operators

    #region operator ParameterDirection(int val)
    public static implicit operator ParameterDirection(int val)
    {
      return Find(val);
    }
    #endregion

    #region operator ParameterDirection(string val)
    public static implicit operator ParameterDirection(string val)
    {
      return Find(val);
    }
    #endregion

    #region operator int(ParameterDirection val)
    public static implicit operator int(ParameterDirection val)
    {
      return val.Value;
    }
    #endregion

    #region operator string(ParameterDirection val)
    public static implicit operator string(ParameterDirection val)
    {
      return val.Text;
    }
    #endregion

    #region operator ==(ParameterDirection lhs, ParameterDirection rhs)
    public static bool operator ==(ParameterDirection lhs, ParameterDirection rhs)
    {
      return lhs.Value == rhs.Value;
    }
    #endregion

    #region operator !=(ParameterDirection lhs, ParameterDirection rhs)
    public static bool operator !=(ParameterDirection lhs, ParameterDirection rhs)
    {
      return lhs.Value != rhs.Value;
    }
    #endregion

    #region operator ==(ParameterDirection lhs, int rhs)
    public static bool operator ==(ParameterDirection lhs, int rhs)
    {
      return lhs.Value == rhs;
    }
    #endregion

    #region operator !=(ParameterDirection lhs, int rhs)
    public static bool operator !=(ParameterDirection lhs, int rhs)
    {
      return lhs.Value != rhs;
    }
    #endregion

    #region operator ==(ParameterDirection lhs, string rhs)
    public static bool operator ==(ParameterDirection lhs, string rhs)
    {
      return lhs.Text.ToLower() == rhs.ToLower();
    }
    #endregion

    #region operator !=(ParameterDirection lhs, string rhs)
    public static bool operator !=(ParameterDirection lhs, string rhs)
    {
      return lhs.Text.ToLower() != rhs.ToLower();
    }
    #endregion
  }

  public class Version
  {
    // Public Constants

    #region Public Constants
    public const int CurrentVal = 1;
    public const int OriginalVal = 2;

    public static readonly Version Unknown = new Version("Unknown", 0);
    public static readonly Version Current = new Version("Current", CurrentVal);
    public static readonly Version Original = new Version("Original", OriginalVal);
    #endregion

    // Public Constructors

    #region Version(string text, int val)
    public Version(string text, int val)
    {
      Text = text;
      Value = val;
    }
    #endregion

    // Public Properties

    #region Text
    public string Text
    {
      get;
      protected set;
    }
    #endregion

    #region Value
    public int Value
    {
      get;
      protected set;
    }
    #endregion

    // Public Methods

    #region ToString()
    public override string ToString()
    {
      return Text;
    }
    #endregion

    #region GetHashCode()
    public override int GetHashCode()
    {
      return Value;
    }
    #endregion

    #region Equals(object o)
    public override bool Equals(object o)
    {
      if (o.GetType() == typeof(int))
        return this.Value == (int) o;

      if (o.GetType() == typeof(string))
        return this.Text == (string) o;

      if (o.GetType() == typeof(Version))
        return this.Value == ((Version) o).Value;

      return false;
    }
    #endregion

    // Public Static Methods

    #region Parse(string text)
    public static Version Parse(string text)
    {
      if (text == null)
        return Unknown;

      switch (text.ToLower())
      {
        case "current":
          return Current;

        case "original":
          return Original;

        default:
          return Unknown;
      }
    }
    #endregion

    #region Find(string text)
    public static Version Find(string text)
    {
      return Parse(text);
    }
    #endregion

    #region Find(int val)
    public static Version Find(int val)
    {
      switch (val)
      {
        case 1:
          return Current;

        case 2:
          return Original;

        default:
          return Unknown;
      }
    }
    #endregion

    // Public Operators

    #region operator Version(int val)
    public static implicit operator Version(int val)
    {
      return Find(val);
    }
    #endregion

    #region operator Version(string val)
    public static implicit operator Version(string val)
    {
      return Find(val);
    }
    #endregion

    #region operator int(Version val)
    public static implicit operator int(Version val)
    {
      return val.Value;
    }
    #endregion

    #region operator string(Version val)
    public static implicit operator string(Version val)
    {
      return val.Text;
    }
    #endregion

    #region operator ==(Version lhs, Version rhs)
    public static bool operator ==(Version lhs, Version rhs)
    {
      return lhs.Value == rhs.Value;
    }
    #endregion

    #region operator !=(Version lhs, Version rhs)
    public static bool operator !=(Version lhs, Version rhs)
    {
      return lhs.Value != rhs.Value;
    }
    #endregion

    #region operator ==(Version lhs, int rhs)
    public static bool operator ==(Version lhs, int rhs)
    {
      return lhs.Value == rhs;
    }
    #endregion

    #region operator !=(Version lhs, int rhs)
    public static bool operator !=(Version lhs, int rhs)
    {
      return lhs.Value != rhs;
    }
    #endregion

    #region operator ==(Version lhs, string rhs)
    public static bool operator ==(Version lhs, string rhs)
    {
      return lhs.Text.ToLower() == rhs.ToLower();
    }
    #endregion

    #region operator !=(Version lhs, string rhs)
    public static bool operator !=(Version lhs, string rhs)
    {
      return lhs.Text.ToLower() != rhs.ToLower();
    }
    #endregion
  }

  public class AutoSync
  {
    // Public Constants

    #region Public Constants
    public const int NeverVal = 1;
    public const int OnInsertVal = 2;
    public const int OnUpdateVal = 3;
    public const int AlwaysVal = 4;
    public const int DefaultVal = 5;

    public static readonly AutoSync Unknown = new AutoSync("Unknown", 0);
    public static readonly AutoSync Never = new AutoSync("Never", NeverVal);
    public static readonly AutoSync OnInsert = new AutoSync("OnInsert", OnInsertVal);
    public static readonly AutoSync OnUpdate = new AutoSync("OnUpdate", OnUpdateVal);
    public static readonly AutoSync Always = new AutoSync("Always", AlwaysVal);
    public static readonly AutoSync Default = new AutoSync("Default", DefaultVal);
    #endregion

    // Public Constructors

    #region AutoSync(string text, int val)
    public AutoSync(string text, int val)
    {
      Text = text;
      Value = val;
    }
    #endregion

    // Public Properties

    #region Text
    public string Text
    {
      get;
      protected set;
    }
    #endregion

    #region Value
    public int Value
    {
      get;
      protected set;
    }
    #endregion

    // Public Methods

    #region ToString()
    public override string ToString()
    {
      return Text;
    }
    #endregion

    #region GetHashCode()
    public override int GetHashCode()
    {
      return Value;
    }
    #endregion

    #region Equals(object o)
    public override bool Equals(object o)
    {
      if (o.GetType() == typeof(int))
        return this.Value == (int) o;

      if (o.GetType() == typeof(string))
        return this.Text == (string) o;

      if (o.GetType() == typeof(AutoSync))
        return this.Value == ((AutoSync) o).Value;

      return false;
    }
    #endregion

    // Public Static Methods

    #region Parse(string text)
    public static AutoSync Parse(string text)
    {
      if (text == null)
        return Unknown;

      switch (text.ToLower())
      {
        case "never":
          return Never;

        case "oninsert":
          return OnInsert;

        case "onupdate":
          return OnUpdate;

        case "always":
          return Always;

        case "default":
          return Default;

        default:
          return Unknown;
      }
    }
    #endregion

    #region Find(string text)
    public static AutoSync Find(string text)
    {
      return Parse(text);
    }
    #endregion

    #region Find(int val)
    public static AutoSync Find(int val)
    {
      switch (val)
      {
        case 1:
          return Never;

        case 2:
          return OnInsert;

        case 3:
          return OnUpdate;

        case 4:
          return Always;

        case 5:
          return Default;

        default:
          return Unknown;
      }
    }
    #endregion

    // Public Operators

    #region operator AutoSync(int val)
    public static implicit operator AutoSync(int val)
    {
      return Find(val);
    }
    #endregion

    #region operator AutoSync(string val)
    public static implicit operator AutoSync(string val)
    {
      return Find(val);
    }
    #endregion

    #region operator int(AutoSync val)
    public static implicit operator int(AutoSync val)
    {
      return val.Value;
    }
    #endregion

    #region operator string(AutoSync val)
    public static implicit operator string(AutoSync val)
    {
      return val.Text;
    }
    #endregion

    #region operator ==(AutoSync lhs, AutoSync rhs)
    public static bool operator ==(AutoSync lhs, AutoSync rhs)
    {
      return lhs.Value == rhs.Value;
    }
    #endregion

    #region operator !=(AutoSync lhs, AutoSync rhs)
    public static bool operator !=(AutoSync lhs, AutoSync rhs)
    {
      return lhs.Value != rhs.Value;
    }
    #endregion

    #region operator ==(AutoSync lhs, int rhs)
    public static bool operator ==(AutoSync lhs, int rhs)
    {
      return lhs.Value == rhs;
    }
    #endregion

    #region operator !=(AutoSync lhs, int rhs)
    public static bool operator !=(AutoSync lhs, int rhs)
    {
      return lhs.Value != rhs;
    }
    #endregion

    #region operator ==(AutoSync lhs, string rhs)
    public static bool operator ==(AutoSync lhs, string rhs)
    {
      return lhs.Text.ToLower() == rhs.ToLower();
    }
    #endregion

    #region operator !=(AutoSync lhs, string rhs)
    public static bool operator !=(AutoSync lhs, string rhs)
    {
      return lhs.Text.ToLower() != rhs.ToLower();
    }
    #endregion
  }

  public class ClassModifier
  {
    // Public Constants

    #region Public Constants
    public const int SealedVal = 1;
    public const int AbstractVal = 2;

    public static readonly ClassModifier Unknown = new ClassModifier("Unknown", 0);
    public static readonly ClassModifier Sealed = new ClassModifier("Sealed", SealedVal);
    public static readonly ClassModifier Abstract = new ClassModifier("Abstract", AbstractVal);
    #endregion

    // Public Constructors

    #region ClassModifier(string text, int val)
    public ClassModifier(string text, int val)
    {
      Text = text;
      Value = val;
    }
    #endregion

    // Public Properties

    #region Text
    public string Text
    {
      get;
      protected set;
    }
    #endregion

    #region Value
    public int Value
    {
      get;
      protected set;
    }
    #endregion

    // Public Methods

    #region ToString()
    public override string ToString()
    {
      return Text;
    }
    #endregion

    #region GetHashCode()
    public override int GetHashCode()
    {
      return Value;
    }
    #endregion

    #region Equals(object o)
    public override bool Equals(object o)
    {
      if (o.GetType() == typeof(int))
        return this.Value == (int) o;

      if (o.GetType() == typeof(string))
        return this.Text == (string) o;

      if (o.GetType() == typeof(ClassModifier))
        return this.Value == ((ClassModifier) o).Value;

      return false;
    }
    #endregion

    // Public Static Methods

    #region Parse(string text)
    public static ClassModifier Parse(string text)
    {
      if (text == null)
        return Unknown;

      switch (text.ToLower())
      {
        case "sealed":
          return Sealed;

        case "abstract":
          return Abstract;

        default:
          return Unknown;
      }
    }
    #endregion

    #region Find(string text)
    public static ClassModifier Find(string text)
    {
      return Parse(text);
    }
    #endregion

    #region Find(int val)
    public static ClassModifier Find(int val)
    {
      switch (val)
      {
        case 1:
          return Sealed;

        case 2:
          return Abstract;

        default:
          return Unknown;
      }
    }
    #endregion

    // Public Operators

    #region operator ClassModifier(int val)
    public static implicit operator ClassModifier(int val)
    {
      return Find(val);
    }
    #endregion

    #region operator ClassModifier(string val)
    public static implicit operator ClassModifier(string val)
    {
      return Find(val);
    }
    #endregion

    #region operator int(ClassModifier val)
    public static implicit operator int(ClassModifier val)
    {
      return val.Value;
    }
    #endregion

    #region operator string(ClassModifier val)
    public static implicit operator string(ClassModifier val)
    {
      return val.Text;
    }
    #endregion

    #region operator ==(ClassModifier lhs, ClassModifier rhs)
    public static bool operator ==(ClassModifier lhs, ClassModifier rhs)
    {
      return lhs.Value == rhs.Value;
    }
    #endregion

    #region operator !=(ClassModifier lhs, ClassModifier rhs)
    public static bool operator !=(ClassModifier lhs, ClassModifier rhs)
    {
      return lhs.Value != rhs.Value;
    }
    #endregion

    #region operator ==(ClassModifier lhs, int rhs)
    public static bool operator ==(ClassModifier lhs, int rhs)
    {
      return lhs.Value == rhs;
    }
    #endregion

    #region operator !=(ClassModifier lhs, int rhs)
    public static bool operator !=(ClassModifier lhs, int rhs)
    {
      return lhs.Value != rhs;
    }
    #endregion

    #region operator ==(ClassModifier lhs, string rhs)
    public static bool operator ==(ClassModifier lhs, string rhs)
    {
      return lhs.Text.ToLower() == rhs.ToLower();
    }
    #endregion

    #region operator !=(ClassModifier lhs, string rhs)
    public static bool operator !=(ClassModifier lhs, string rhs)
    {
      return lhs.Text.ToLower() != rhs.ToLower();
    }
    #endregion
  }

  public class MemberModifier
  {
    // Public Constants

    #region Public Constants
    public const int VirtualVal = 1;
    public const int OverrideVal = 2;
    public const int NewVal = 3;
    public const int NewVirtualVal = 4;

    public static readonly MemberModifier Unknown = new MemberModifier("Unknown", 0);
    public static readonly MemberModifier Virtual = new MemberModifier("Virtual", VirtualVal);
    public static readonly MemberModifier Override = new MemberModifier("Override", OverrideVal);
    public static readonly MemberModifier New = new MemberModifier("New", NewVal);
    public static readonly MemberModifier NewVirtual = new MemberModifier("NewVirtual", NewVirtualVal);
    #endregion

    // Public Constructors

    #region MemberModifier(string text, int val)
    public MemberModifier(string text, int val)
    {
      Text = text;
      Value = val;
    }
    #endregion

    // Public Properties

    #region Text
    public string Text
    {
      get;
      protected set;
    }
    #endregion

    #region Value
    public int Value
    {
      get;
      protected set;
    }
    #endregion

    // Public Methods

    #region ToString()
    public override string ToString()
    {
      return Text;
    }
    #endregion

    #region GetHashCode()
    public override int GetHashCode()
    {
      return Value;
    }
    #endregion

    #region Equals(object o)
    public override bool Equals(object o)
    {
      if (o.GetType() == typeof(int))
        return this.Value == (int) o;

      if (o.GetType() == typeof(string))
        return this.Text == (string) o;

      if (o.GetType() == typeof(MemberModifier))
        return this.Value == ((MemberModifier) o).Value;

      return false;
    }
    #endregion

    // Public Static Methods

    #region Parse(string text)
    public static MemberModifier Parse(string text)
    {
      if (text == null)
        return Unknown;

      switch (text.ToLower())
      {
        case "virtual":
          return Virtual;

        case "override":
          return Override;

        case "new":
          return New;

        case "newvirtual":
          return NewVirtual;

        default:
          return Unknown;
      }
    }
    #endregion

    #region Find(string text)
    public static MemberModifier Find(string text)
    {
      return Parse(text);
    }
    #endregion

    #region Find(int val)
    public static MemberModifier Find(int val)
    {
      switch (val)
      {
        case 1:
          return Virtual;

        case 2:
          return Override;

        case 3:
          return New;

        case 4:
          return NewVirtual;

        default:
          return Unknown;
      }
    }
    #endregion

    // Public Operators

    #region operator MemberModifier(int val)
    public static implicit operator MemberModifier(int val)
    {
      return Find(val);
    }
    #endregion

    #region operator MemberModifier(string val)
    public static implicit operator MemberModifier(string val)
    {
      return Find(val);
    }
    #endregion

    #region operator int(MemberModifier val)
    public static implicit operator int(MemberModifier val)
    {
      return val.Value;
    }
    #endregion

    #region operator string(MemberModifier val)
    public static implicit operator string(MemberModifier val)
    {
      return val.Text;
    }
    #endregion

    #region operator ==(MemberModifier lhs, MemberModifier rhs)
    public static bool operator ==(MemberModifier lhs, MemberModifier rhs)
    {
      return lhs.Value == rhs.Value;
    }
    #endregion

    #region operator !=(MemberModifier lhs, MemberModifier rhs)
    public static bool operator !=(MemberModifier lhs, MemberModifier rhs)
    {
      return lhs.Value != rhs.Value;
    }
    #endregion

    #region operator ==(MemberModifier lhs, int rhs)
    public static bool operator ==(MemberModifier lhs, int rhs)
    {
      return lhs.Value == rhs;
    }
    #endregion

    #region operator !=(MemberModifier lhs, int rhs)
    public static bool operator !=(MemberModifier lhs, int rhs)
    {
      return lhs.Value != rhs;
    }
    #endregion

    #region operator ==(MemberModifier lhs, string rhs)
    public static bool operator ==(MemberModifier lhs, string rhs)
    {
      return lhs.Text.ToLower() == rhs.ToLower();
    }
    #endregion

    #region operator !=(MemberModifier lhs, string rhs)
    public static bool operator !=(MemberModifier lhs, string rhs)
    {
      return lhs.Text.ToLower() != rhs.ToLower();
    }
    #endregion
  }

  public class Cardinality
  {
    // Public Constants

    #region Public Constants
    public const int OneVal = 1;
    public const int ManyVal = 2;

    public static readonly Cardinality Unknown = new Cardinality("Unknown", 0);
    public static readonly Cardinality One = new Cardinality("One", OneVal);
    public static readonly Cardinality Many = new Cardinality("Many", ManyVal);
    #endregion

    // Public Constructors

    #region Cardinality(string text, int val)
    public Cardinality(string text, int val)
    {
      Text = text;
      Value = val;
    }
    #endregion

    // Public Properties

    #region Text
    public string Text
    {
      get;
      protected set;
    }
    #endregion

    #region Value
    public int Value
    {
      get;
      protected set;
    }
    #endregion

    // Public Methods

    #region ToString()
    public override string ToString()
    {
      return Text;
    }
    #endregion

    #region GetHashCode()
    public override int GetHashCode()
    {
      return Value;
    }
    #endregion

    #region Equals(object o)
    public override bool Equals(object o)
    {
      if (o.GetType() == typeof(int))
        return this.Value == (int) o;

      if (o.GetType() == typeof(string))
        return this.Text == (string) o;

      if (o.GetType() == typeof(Cardinality))
        return this.Value == ((Cardinality) o).Value;

      return false;
    }
    #endregion

    // Public Static Methods

    #region Parse(string text)
    public static Cardinality Parse(string text)
    {
      if (text == null)
        return Unknown;

      switch (text.ToLower())
      {
        case "one":
          return One;

        case "many":
          return Many;

        default:
          return Unknown;
      }
    }
    #endregion

    #region Find(string text)
    public static Cardinality Find(string text)
    {
      return Parse(text);
    }
    #endregion

    #region Find(int val)
    public static Cardinality Find(int val)
    {
      switch (val)
      {
        case 1:
          return One;

        case 2:
          return Many;

        default:
          return Unknown;
      }
    }
    #endregion

    // Public Operators

    #region operator Cardinality(int val)
    public static implicit operator Cardinality(int val)
    {
      return Find(val);
    }
    #endregion

    #region operator Cardinality(string val)
    public static implicit operator Cardinality(string val)
    {
      return Find(val);
    }
    #endregion

    #region operator int(Cardinality val)
    public static implicit operator int(Cardinality val)
    {
      return val.Value;
    }
    #endregion

    #region operator string(Cardinality val)
    public static implicit operator string(Cardinality val)
    {
      return val.Text;
    }
    #endregion

    #region operator ==(Cardinality lhs, Cardinality rhs)
    public static bool operator ==(Cardinality lhs, Cardinality rhs)
    {
      return lhs.Value == rhs.Value;
    }
    #endregion

    #region operator !=(Cardinality lhs, Cardinality rhs)
    public static bool operator !=(Cardinality lhs, Cardinality rhs)
    {
      return lhs.Value != rhs.Value;
    }
    #endregion

    #region operator ==(Cardinality lhs, int rhs)
    public static bool operator ==(Cardinality lhs, int rhs)
    {
      return lhs.Value == rhs;
    }
    #endregion

    #region operator !=(Cardinality lhs, int rhs)
    public static bool operator !=(Cardinality lhs, int rhs)
    {
      return lhs.Value != rhs;
    }
    #endregion

    #region operator ==(Cardinality lhs, string rhs)
    public static bool operator ==(Cardinality lhs, string rhs)
    {
      return lhs.Text.ToLower() == rhs.ToLower();
    }
    #endregion

    #region operator !=(Cardinality lhs, string rhs)
    public static bool operator !=(Cardinality lhs, string rhs)
    {
      return lhs.Text.ToLower() != rhs.ToLower();
    }
    #endregion
  }
}
